-- treasure_get_item
-- created by zhuangsl
-- 每获得一件宝物，额外获得材料

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 进入迷宫后获得材料抽取
    trigger = function(who, prop, arg)
        -- 物品阶位，对概率有加成
        local rank = ItemM.query(arg, "rank");
        local rate = (rank - 1) * prop[4] + prop[3];
        
        -- 概率不满足
        local rand = DungeonM.getRandSeed("treasure_get_item") % 1000;
        if rand >= rate then
            return false;
        end

        local classId = tonumber(prop[2]);
        local ret = {1, classId, 1};

        BonusM.doBonus(ret, "treasure_get_item");

        EventMgr.fire(event.TREASURE_GET_MATERIAL, { ["bonus"] = ret, });

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });
        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
